package meal;

/*
 * Nathaniel Cherry:cherryn | Updated: 10.24.11 - Modified constructors to use
 * 		the setter methods.
 * Nathaniel Cherry:cherryn | Updated: 10.23.11 - Changed "ingredient" to "name"
 * 		and fixed the order of the parameters in the methods.
 * Margarita Lee:mleeli | Updated: 10.23.11 - Changed type and number variables
 * 		to units and quantities.
 * Margarita Lee:mleeli | Updated: 10.23.11 - Constructor, set and get methods.
 * Margarita Lee:mleeli | Updated: 10.18.11 -
 *
 */

/**
 * The ingredient container represents the amount and name of an ingredient
 * used in a recipe. The amount consists of a quantity and the units that
 * represent the quantity. If the units are <code>Null</code> the ingredient
 * can be assumed to be such that it consists of some whole unit in and of
 * itself, and the amount of said ingredient will be the the quantity.
 */
public class Ingredient implements Comparable{
	////Margarita Lee:mleeli | Last Updated: 10.23.11 | Changed type and number variables to units and quantity.
	//Task: Define the variables.
	private String name, units;
	private int quantity;

	//Margarita Lee:mleeli | Last Updated: 10.18.11
	//Task: Null constructor.
	//Margarita Lee: mleeli| Last Updated:10.23.11
	//Task: Updated the constructor.
	/**
	 * Creates an ingredient with no name or units and a quantity of zero.
	 */
	// Last updated: 10.18.11
	public Ingredient(){

	}
	public Ingredient(String name) {
		setName(name);
	}
	//Margarita Lee:mleeli | Last Updated: 10.23.11
	//Task: Unformatted constructor.
	//Task: Updated the quantity variable.
	/**
	 * Creates an ingredient with the specified name and quantity.
	 * @param name name of ingredient.
	 * @param qty amount of ingredient.
	 */
	// Last updated 10.24.11 - changed to use setter methods.
	public Ingredient(String name, int qty){
		setName(name);
		setQuantity(qty);
	}

	//Margarita Lee: mleeli | Last Updated: 10.19.11
	//Task: Formatted constructor.
	//Last Margarita Lee: mleeli |Updated: 10.23.11
	//Task: Updated the quantity and units variables.
	//
	/**
	 * Created an ingredient with the specified name and quantity in units.
	 * @param name name of the ingredient.
	 * @param qty amount of the ingredient.
	 * @param units units used in specifying the amount.
	 */
	// Last updated 10.23.11
	public Ingredient(String name, int qty, String units){
		setIngredient(name,qty,units);
	}

	//Margarita Lee:mleeli | Last Updated: 10.18.11
	//Task: set method called setIngredient that allows the content of ingredient, quantity and units  to be stored in another String value if required.
	//Margarita Lee: mleeli| Last Updated: 10.23.11
	//Task: Updated the int quantity and String units.
	//Start of the set methods.
	/**
	 * Set the ingredient to be of the specified name and amount.
	 * @param name name of the ingredient.
	 * @param qty amount of the ingredient.
	 * @param units units used in specifying the amount.
	 *
	 */
	// Last updated 10.23.11
	public void setIngredient(String name, int qty, String units){
		setName(name);
		setQuantity(qty);
		setUnits(units);
	}
	//Margarita Lee:mleeli | Last Updated: 10.18.11
	//Task: setIngredient method that allows the content of ingredient to be changed to store another String value if its required.
	/**
	 * Set the name of this ingredient to the specified name.
	 * @param name the name of the ingredient.
	 */
	// Last updated 10.23.11 - setIngredient, renamed to reflect move to "name".
	public void setName(String name){
		this.name = name;
	}
	//Margarita Lee:mleeli | Last Updated: 10.18.11
	//Task: setNumber method that allows the content of quantity to be changed to store another String value if its required.
	//Margarita Lee: mleeli| Last Updated: 10.23.11
	//Task: Updated the quantity variable to this.quantity for more specification.
	/**
	 * Set the quantity of the ingredient.
	 * @param q amount of the ingredient.
	 */
	// Last updated 10.23.11 - quantity -> this.quantity for clarity.
	public void setQuantity(int q){
		this.quantity = q;
	}

	//Margarita Lee:mleeli | Last Updated: 10.19.11
	//Task: setType method that allows the content of units  to be changed to store another String value if its required.
	//Margarita Lee: mleeli| Last Updated: 10.23.11
	//Task: Updated the units variable to this.unit for more specification.
	/**
	 * Set the units used to specify the amount to the value specified.
	 * Modifying the units does not scale the quantity. So, for example
	 * changing the units to grams from pounds will simply modify an
	 * ingredient of 16 grams to be 16 pounds.
	 * @param u units of measurement used to specify amount of ingredient.
	 */
	// Last updated 10.23.11 - units -> this.units for clarity.
	public void setUnits(String u){
		this.units = u;
	}

	//Margarita Lee:mleeli | Last Updated: 10.18.11
	//Task: getIngredient method that returns the String ingredient for when the object calls it.
	//Start of the get methods.
	//Margarita Lee: mleeli| Last Updated:10.23.11
	//Task: Updated the variable ingredients to this.ingredients for more specification.
	/**
	 * Returns the name of the ingredient.
	 * @return the name which refers to the ingredient.
	 */
	// Last updated 10.24.11 - from getIngredient() to reflect change to "name".
	public String getName(){
		return this.name;
	}
	//Margarita Lee:mleeli | Last Updated: 10.18.11
	//Task: getNumber method that returns the integer number for when the object calls it.
	//Margarita Lee: mleeli| Last Updated: 10.23.11
	//Task: Updated the variable quantity to this.quantity for more specification.
	/**
	 * Returns the quantity of the ingredient.
	 * @return the quantity of the ingredient.
	 */
	// Last updated 10.24.11 - quantity -> this.quantity for clarity.
	public int getQuantity(){
		return this.quantity;
	}

	//Margarita Lee: mleeli | Last Updated: 10.19.11
	//Task: getType method that returns the String type for when the object calls it.
	//Margarita Lee: mleeli| Last Updated: 10.23.11
	//Task: Update the variable units to this.units for more specification.
	/**
	 * Returns the units associated with the ingredient.
	 * @return units which the amount has been specified in.
	 */
	// Last updated 10.24.11 - units->this.units for clarity.
	public String getUnits(){
		return this.units;
	}

	//Margarita Lee: mleeli | Last Updated: 10.23.11
	//Task: Created the compareTO method that compares this.getIngredient and that.getIngredients.
	//Nathaniel Cherry: cherryn | Updated: 10.23.11
	//Task: Fixed compareTo method so that it conforms to the comparable interface.
	/**
	 * Compares two ingredients based on the lexicographical order of their
	 * names.
	 */
	// Last updated 10.24.11 - getIngredient()->getName()
	public int compareTo(Object that){
		return this.getName().compareTo(((Ingredient)that).getName());
	}

	//Margarita Lee:mleeli | Last Updated: 10.23.11
	//Task: Updated the method to toString and added the String s with the variables quantity, units and ingredient.
	/**
	 * Returns a string representation of this ingredient. Of the form "<code>quantity units name</code>".
	 * @return a string representation of this ingredient.
	 */
	public String toString(){
		String s = getQuantity() + " " + getUnits() + " " + getName();
		return s;
	}
}
